<extend name="Index/index" />

<block name="mycss"></block>

<block name="main">
    <div class="container">
        <div class="row">
            
            <!-- 主体搜索主体内容 -->
            <div class="col-md-7 col-md-offset-1">
                
                <!-- 类型选择 -->
                <div class="w100 searchlist">
                    <ul>
                        <li><a href="<{:U('Search/index', array(type=>'question','name'=>$name))}>">问题</a></li>
                        <li><a href="<{:U('Search/index', array(type=>'article','name'=>$name))}>">文章</a></li>
                        <li><a href="<{:U('Search/index', array(type=>'user','name'=>$name))}>">用户</a></li>
                        <li><a href="<{:U('Search/index', array(type=>'topic','name'=>$name))}>">话题</a></li>
                    </ul>
                </div>
                <div class="clearfix"></div>
                <div class="divline"></div>
                <!-- 内容展示 -->
                <div class="w100">
                    <div class="mt30"> <!-- 间隔 -->
                        <!-- 问题 -->
                        <if condition="$type eq 'question'">
                            <!-- 判断数据是否为空 -->
                            <empty name="data">
                                <div class="w100 h5 mt10 text-center" style="background-color:#eee; height: 80px; line-height: 80px;">暂无更多相关问题</div>
                            <else/>
                                <div class="w100 h5 text-center" style="background-color:#eee; height: 50px; line-height: 50px;">以下为您显示搜索到的相关问题
                                </div>
                                <div class="mt10"></div>
                                <!-- 遍历搜索到的问题 -->
                                <div class="w100 mt10">
                                    <volist name="data" id="voq">
                                        <div class="w100"  style="height:30px;">
                                            <a href="<{:U('Question/detail','qid='.$voq['id'])}>" target="_blank"><{$voq.name}></a>
                                            <a class="h6" style="color:#000" href="<{:U('People/index','uid='.$voq['user_id'])}>" target="_blank"><{$voq.user_name}></a>
                                        </div>
                                    </volist>
                                </div>

                                <div class="w100 mt20 mb30">
                                    <a href="<{:U('Search/index', array('name'=>$name, 'type'=>'question','p'=>$p))}>" class="btn btn-sm btn-default form-control">查看更多相关问题</a>
                                </div>
                            </empty>
                        </if>

                        <!-- 文章 -->
                        <if condition="$type eq 'article'">
                            <!-- 判断数据是否为空 -->
                            <empty name="data">
                                <div class="w100 h5 mt10 text-center" style="background-color:#eee; height: 80px; line-height: 80px;">暂无更多相关文章</div>
                            <else/>
                                <div class="w100 h5 text-center" style="background-color:#eee; height: 50px; line-height: 50px;">以下为您显示搜索到的相关文章
                                </div>
                                <div class="mt10"></div>
                                <!-- 遍历搜索到的文章 -->
                                <div class="w100 mt10">
                                    <volist name="data" id="voa">
                                        <div class="w100"  style="height:30px;">
                                            <a href="<{:U('Article/show','arid='.$voa['id'])}>" target="_blank"><{$voa.title}></a>
                                        </div>
                                    </volist>
                                </div>

                                <div class="w100 mt20 mb30">
                                    <a href="<{:U('Search/index', array('name'=>$name, 'type'=>'article','p'=>$p))}>" class="btn btn-sm btn-default form-control">查看更多相关文章</a>
                                </div>
                            </empty>
                        </if>

                        <!-- 用户 -->
                        <if condition="$type eq 'user'">
                            <!-- 判断数据是否为空 -->
                            <empty name="data">
                                <div class="w100 h5 mt10 text-center" style="background-color:#eee; height: 80px; line-height: 80px;">暂无更多相关用户</div>
                            <else/>
                                <div class="w100 h5 text-center" style="background-color:#eee; height: 50px; line-height: 50px;">以下为您显示搜索到的相关 用户
                                </div>
                                <div class="mt10"></div>
                                <!-- 遍历搜索到的用户 -->
                                <div class="w100 mt10">
                                    <volist name="data" id="vou">
                                        <div class="w100 mt40" style="height:80px">
                                            <div class="w50 pull-left">
                                                <a href="<{:U('People/index','uid='.$vou['id'])}>" target="_blank"><img src="__PUBLIC__/imgs/<{$vou.image}>" width="45px" height="45px"></a>
                                                <a href="<{:U('People/index','uid='.$vou['id'])}>" target="_blank"><{$vou.name}></a>
                                                
                                            </div>
                                            <div class="w50 pull-right text-right">
                                                <a href="" user_id="<{$vou.id}>" class="btn btn-sm btn-default attend_u" style="margin-left:150px;">关注</a>
                                            </div>
                                            <div class="clearfix"></div>
                                            <div class="divline"></div>
                                        </div>
                                    </volist>
                                </div>
                                <div></div>
                                <div class="w100 mt20 mb30">
                                    <a href="<{:U('Search/index', array('name'=>$name, 'type'=>'user','p'=>$p))}>" class="btn btn-sm btn-default form-control">查看更多相关用户</a>
                                </div>
                            </empty>
                        </if>

                        <!-- 话题 -->
                        <if condition="$type eq 'topic'">
                            <!-- 判断数据是否为空 -->
                            <empty name="data">
                                <div class="w100 h5 mt10 text-center" style="background-color:#eee; height: 80px; line-height: 80px;">暂无更多相关话题</div>
                            <else/>
                                <div class="w100 h5 text-center" style="background-color:#eee; height: 50px; line-height: 50px;">以下为您显示搜索到的相关 话题
                                </div>
                                <div class="mt10"></div>
                                <!-- 遍历搜索到的用户 -->
                                <div class="w100 mt10">
                                    <volist name="data" id="vot">
                                        <div class="w100 mt40" style="height:80px">
                                            <div class="w50 pull-left">
                                                <a href="<{:U('Topics/index','tid='.$vot['id'])}>" target="_blank"><img src="__PUBLIC__/imgs/<{$vot.image}>" width="45px" height="45px"></a>
                                                <a href="<{:U('Topics/index','tid='.$vot['id'])}>" target="_blank"><{$vot.name}></a>
                                                
                                            </div>
                                            <div class="w50 pull-right text-right">
                                                <a href="" topic_id="<{$vot.id}>" class="btn btn-sm btn-default attend_t" style="margin-left:150px;">关注</a>
                                            </div>
                                            <div class="clearfix"></div>
                                            <div class="divline"></div>
                                        </div>
                                    </volist>
                                </div>
                                <div></div>
                                <div class="w100 mt20 mb30">
                                    <a href="<{:U('Search/index', array('name'=>$name, 'type'=>'topic','p'=>$p))}>" class="btn btn-sm btn-default form-control">查看更多相关话题</a>
                                </div>
                            </empty>
                        </if>

                    </div>

                </div>

            </div>


            <!-- 右侧留空 -->
            <div class="col-md-3"></div>
        </div>
    </div>




</block>

<block name="myjs">
    
<script type="text/javascript">
     // 关注用户 的触发事件(群体)
            var uattend = $('a.attend_u');
            for (var i = 0; i < uattend.length; i++) {
                $(uattend[i]).click(function(){
                    // console.log($(this));
                    var uid = $(this).attr('user_id')
                    // console.log(uid);
                    // 判断a标签是关注还是否
                    if ($(this).text() == '关注') {
                        $.ajax({
                            type: 'get',
                            url: "<{:U('Attend/attendU')}>",
                            data: 'id=' + uid,
                        });
                        $(this).text('取消关注');
                    } else {
                        $.ajax({
                            type: 'get',
                            url: "<{:U('Attend/notAttendU')}>",
                            data: 'id=' + uid,
                        });
                        $(this).html('关注');
                    };
                    return false; //阻止跳转
                });
            }; // 关注用户点击事件结束


            var tattend = $('a.attend_t');
            for (var i = 0; i < tattend.length; i++) {
                $(tattend[i]).click(function(){
                    // console.log($(this));
                    var tid = $(this).attr('topic_id');
                    // console.log(uid);
                    // 判断a标签是关注还是否
                    if ($(this).text() == '关注') {
                        $.ajax({
                            type: 'get',
                            url: "<{:U('Attend/attendT')}>",
                            data: 'id=' + tid,
                        });
                        $(this).text('取消关注');
                    } else {
                        $.ajax({
                            type: 'get',
                            url: "<{:U('Attend/notAttendT')}>",
                            data: 'id=' + tid,
                        });
                        $(this).html('关注');
                    };
                    return false; //阻止跳转
                });
            }; // 关注话题点击事件结束

</script>

</block>


